#!/bin/bash

echo "#Update $HSTA_BENCHMARK.tcl for power profiling"
echo "#Author: Min Li, Contact: mli46@wisc.edu"
echo -ne "#Modified Date: "
date
echo 

## paste the sw file and prob file
let "HSTA_SET_CNT=$1+7"

echo "#Input files for parsing are: "
echo "#"$HSTA_CONTROL_INPUT_FILE
echo "#"$HSTA_REGION_FILE
echo "#"$HSTA_CUR_SW_FILE
echo "#"$HSTA_TCL_FILE

## parsing the switching activity info
echo "#**********Set SW for certain signals**************"
#awk -v set_cnt=$HSTA_SET_CNT '{print "set_switching_activity -static_probability", \
#$set_cnt, "-state_condition \"default\" [get_net ", $1, "]" }' $HSTA_SW_FILE
cd $HSTA_BENCHMARK_DIR
paste $HSTA_PROB_FILE $HSTA_CUR_SW_FILE > $HSTA_UNIQ_TMP_FILE
awk -v set_cnt=$HSTA_SET_CNT '{print $set_cnt}' $HSTA_UNIQ_TMP_FILE > temp.txt
#awk '{if(/set_switching_activity/) { getline content < "temp.txt"; $5=content; print $0 } else {print}}' $HSTA_TCL_FILE > $HSTA_UNIQ_TMP_FILE && mv $HSTA_UNIQ_TMP_FILE $HSTA_TCL_FILE 
awk '{if(/set_switching_activity/) { getline content < "temp.txt"; $5=content; print $0 } else {print}}' $HSTA_TCL_TEMPLATE_FILE > $HSTA_TCL_FILE 
echo

## power_report
echo "#***************Output power report****************"
#echo "report_power_groups"
echo "report_power -verbose"
echo "exit"
echo
